-
Notifications
You must be signed in to change notification settings - Fork 0
Add CLI lifecycle integration tests with vitest #50
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
- Add vitest as dev dependency to packages/cli - Create comprehensive integration test verifying full CLI lifecycle: init → content creation → build - Fix outputFileTracingRoot in next.config.mjs to allow Turbopack to resolve content files outside the .fumadocs project root - Update packages/cli test script from placeholder to vitest run Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
🚀 Preview DeploymentThis pull request will be automatically deployed to Vercel. Preview Links
Build StatusCheck the CI workflow for build status and any errors. Automated preview information for PR #50 |
Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
🚀 Preview DeploymentThis pull request will be automatically deployed to Vercel. Preview Links
Build StatusCheck the CI workflow for build status and any errors. Automated preview information for PR #50 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Adds end-to-end CLI lifecycle integration coverage (init → content → build → migrate) using Vitest, and updates the site’s Next.js config to fix Turbopack file tracing for content outside the project root.
Changes:
- Add Vitest-based CLI lifecycle integration test suite covering init/build/migrate.
- Add Vitest configuration + wire up
pnpm testforpackages/cli. - Update
packages/site/next.config.mjswithoutputFileTracingRootto fix init/build workflows under Next.js/Turbopack.
Reviewed changes
Copilot reviewed 4 out of 5 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
| pnpm-lock.yaml | Adds vitest (and transitive toolchain) to the workspace lockfile. |
| packages/site/next.config.mjs | Sets outputFileTracingRoot for broader file tracing scope. |
| packages/cli/vitest.config.mjs | Adds long timeouts suitable for end-to-end integration tests. |
| packages/cli/test/cli-lifecycle.test.mjs | New sequential lifecycle integration tests executing real CLI commands. |
| packages/cli/package.json | Switches test to vitest run and adds vitest devDependency. |
Files not reviewed (1)
- pnpm-lock.yaml: Language not supported
| const __dirname = path.dirname(__filename); | ||
|
|
||
| const CLI_PATH = path.resolve(__dirname, '../bin/cli.mjs'); | ||
| const MONOREPO_ROOT = path.resolve(__dirname, '../../..'); |
Copilot
AI
Feb 9, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
MONOREPO_ROOT is declared but never used. Please remove it to avoid confusion about whether the tests depend on monorepo paths.
| const MONOREPO_ROOT = path.resolve(__dirname, '../../..'); |
| function runCli(args, options = {}) { | ||
| const { cwd = testDir, env: extraEnv = {}, timeout = 300_000 } = options; | ||
| return execFileSync(process.execPath, [CLI_PATH, ...args], { | ||
| cwd, | ||
| timeout, |
Copilot
AI
Feb 9, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
runCli defaults to a 5-minute execFileSync timeout, but the vitest config allows 10 minutes. Long npm install / next build runs could be killed by the shorter process timeout even though the test timeout hasn’t elapsed. Consider bumping the default to match the vitest timeout (or threading it through from config).
| }); | ||
| } | ||
|
|
||
| describe('CLI Lifecycle: init → content → build', () => { |
Copilot
AI
Feb 9, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These tests rely on shared state across multiple it(...) blocks. To prevent future flakiness if vitest is configured to run tests concurrently, make the suite explicitly sequential (e.g., describe.sequential(...) or equivalent vitest sequencing config).
| describe('CLI Lifecycle: init → content → build', () => { | |
| describe.sequential('CLI Lifecycle: init → content → build', () => { |
| "devDependencies": { | ||
| "vitest": "^4.0.18" | ||
| } |
Copilot
AI
Feb 9, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Adding vitest (which requires Node >=20 per the lockfile) changes the effective Node baseline for this workspace/package, but package.json doesn’t declare an engines.node range. Consider adding engines (and aligning CI/release, which currently uses Node 18) or pinning to a Vitest version compatible with the supported Node version.
| vite@7.3.1: | ||
| resolution: {integrity: sha512-w+N7Hifpc3gRjZ63vYBXA56dvvRlNWRczTdmCBBa+CotUzAPf5b7YMdMR/8CQoeYE5LX3W4wj6RYTgonm1b9DA==} | ||
| engines: {node: ^20.19.0 || >=22.12.0} | ||
| hasBin: true |
Copilot
AI
Feb 9, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
vite@7.3.1 declares a strict Node engine requirement (^20.19.0 || >=22.12.0). Since this is now in the lockfile, installs on Node 18 will fail and even “Node 20” environments must be new enough. Align supported Node versions/CI (or pin to a toolchain that supports the intended Node baseline).
| vitest@4.0.18: | ||
| resolution: {integrity: sha512-hOQuK7h0FGKgBAas7v0mSAsnvrIgAvWmRFjmzpJ7SwFHH3g1k2u37JtYwOwmEKhK6ZO3v9ggDBBm0La1LCK4uQ==} | ||
| engines: {node: ^20.0.0 || ^22.0.0 || >=24.0.0} | ||
| hasBin: true |
Copilot
AI
Feb 9, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
vitest@4.0.18 requires Node ^20.0.0 || ^22.0.0 || >=24.0.0. Please ensure the repo’s documented/CI Node version matches this (the release workflow currently uses Node 18), or pin Vitest to a version that supports the older runtime.
| */ | ||
|
|
||
| import { describe, it, expect, beforeAll, afterAll } from 'vitest'; | ||
| import { execSync, execFileSync } from 'child_process'; |
Copilot
AI
Feb 9, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
execSync is imported but never used in this test file. Removing unused imports keeps the integration test easier to maintain and avoids lint/tooling warnings if added later.
| import { execSync, execFileSync } from 'child_process'; | |
| import { execFileSync } from 'child_process'; |
End-to-end tests for the complete user workflow:
objectdocs init→ content creation →objectdocs build→objectdocs migrate.Tests (
packages/cli/test/cli-lifecycle.test.mjs)6 sequential tests in a shared temp directory mirroring real usage:
objectdocs init—.fumadocs/scaffolded,content/package.jsonwith scripts,.gitignoreupdated, deps installedmeta.json,docs.site.jsonwritten and validatedobjectdocs build— Next.js production build produces.nextoutputobjectdocs migrate—.md→.mdxwith frontmatter extraction, H1 removal, body preservation,meta.jsonupdateBug fix (
packages/site/next.config.mjs)The
initworkflow was broken: Turbopack (Next.js 16) cannot resolve imports outside the project root. Content lives at../../docs/relative to.fumadocs/.source/, which is outside.fumadocs/.This extends Turbopack's resolution scope to include the content directory. Monorepo build is unaffected.
Infrastructure
vitesttopackages/clidevDependenciesvitest.config.mjswith 600s timeout for integration testsecho "No test"→vitest run💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.